﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace StudentManagement
{
    public partial class frmTianjia : Form
    {
        public frmTianjia()
        {
            InitializeComponent();
        }

        private void btnadd_Click(object sender, EventArgs e)
        {
            Student s = new Student();
            s.Id = this.txtid.Text;
            s.Name = this.txtname.Text;
            s.Sex = this.cbsex.Text;
            s.Birthday = this.combirthday.Text;
            s.Policy = this.cbpolicy.Text;
            s.Nation = this.cbnation.Text;
            s.IdCard = this.txtidCard.Text;
            string connstr = "server=.;database=Class;user=sa;password=123456";
            SqlConnection conn = new SqlConnection(connstr);
            string insertSql = "insert into student values('" + s.Id + "','" + s.Name + "','"+s.Sex+"','"+s.Birthday+"','"+s.Policy+"','"+s.Nation+"','"+s.IdCard+"') ";
            SqlCommand comm = new SqlCommand(insertSql, conn);
            conn.Open();
            int count = comm.ExecuteNonQuery();
            conn.Close();
            if (count > 0)
            {
                this.DialogResult = DialogResult.OK;
            }
        }

  
    }
}
